package intelligentcity.model.streets;

import intelligentcity.model.Move;
import intelligentcity.model.Point;

public abstract class OneWayStreet {

    protected Point p1;
    protected Point p2;
    protected Move move;

    public OneWayStreet(int x1, int y1, int x2, int y2) {
        p1 = new Point(x1, y1);
        p2 = new Point(x2, y2);
    }

    public OneWayStreet(Point p1, Point p2) {
        this.p1 = p1;
        this.p2 = p2;
    }

    public Point getP1() {
        return p1;
    }

    public void setP1(Point p1) {
        this.p1 = p1;
    }

    public boolean contains(int x, int y) {
        return contains(new Point(x, y));
    }

    public abstract boolean contains(Point point);

    public Move getMove() {
        return move;
    }

    public Point getP2() {
        return p2;
    }

    public void setP2(Point p2) {
        this.p2 = p2;
    }

    @Override
    public String toString() {
        return p1.toString() + "-" + p2.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof OneWayStreet && ((OneWayStreet) o).getP1().equals(p1) && ((OneWayStreet) o).getP2().equals(p2)
                && ((OneWayStreet) o).getMove().equals(move)) {
            return true;
        }
        return false;
    }

}
